package demon1;

import javax.lang.model.element.AnnotationMirror;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-01-12
 * Time:1:55
 */
interface IRunning{
    void running();
}
interface ISwimming{
    void swimming();
}
class Animal{
    String name;
    int age;
    public Animal(String name,int age){
        this.name=name;
        this.age=age;
    }
    public void eat(){
        System.out.println(name+"在吃饭");
    }
}

/**
 * 接口的调用用implements
 * 接口的调用在继承后面
 * 可以一个类引用多个接口，多个接口用","分割，不用再次使用implements
 */
class Dog extends Animal implements IRunning,ISwimming{


    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void running() {
        System.out.println(name+"在跑");
    }

    @Override
    public void swimming() {
        System.out.println(name+"在游泳");
    }

    @Override
    public void eat() {
        System.out.println(name+"在吃狗粮");
    }
}
public class Test1 {
    public static void move(IRunning iRunning){
        iRunning.running();
    }
    public static void eat(Animal animal){
        animal.eat();
    }
    public static void main(String[] args) {
        move(new Dog("huahua",5));
        eat(new Dog("wangcai",4));
    }
    public static void main1(String[] args) {
        Dog dog=new Dog("huahua",5);
        dog.running();
        dog.swimming();
    }

}
